package cn.itsource.ymcc.service.impl;

import cn.itsource.ymcc.domain.MessageBlack;
import cn.itsource.ymcc.mapper.MessageBlackMapper;
import cn.itsource.ymcc.service.IMessageBlackService;
import cn.itsource.ymcc.util.AssertUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Eric Chen
 * @since 2022-07-12
 */
@Service
public class MessageBlackServiceImpl extends ServiceImpl<MessageBlackMapper, MessageBlack> implements IMessageBlackService {

    @Override
    public boolean insert(MessageBlack entity) {
        String tel = entity.getTel();
        EntityWrapper<MessageBlack> Wrapper = new EntityWrapper<>();
        Wrapper.eq("tel",tel);
        MessageBlack messageBlack = selectOne(Wrapper);
        AssertUtil.isNull(messageBlack,"该号码已经是黑名单");
        return super.insert(entity);
    }
}
